#include "config.h"

#include <stdio.h>
#include <sys/stat.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_ASSERT_H
#include <assert.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

/*------------------------------------------------------------------
 * Gattrib specific includes
 *------------------------------------------------------------------*/
#include <libgeda/libgeda.h>       /* geda library fcns  */
#include "struct.h"     /* typdef and struct declarations */
#include "prototype.h"  /* function prototypes */
#include "globals.h"
#include "i_vars.h"

#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif

/* GtkWidget *w_main; */


/* ---------------------------------------------------------------------- */
/*! \brief Register Scheme functions
 *
 * This function registers the Scheme functions required to use
 * gattrib.  They are mostly unnecessary, except for reading in the gattribrc
 * file at the beginning of the prog which gives the library search paths.
 */
void g_register_funcs(void)
{
  /* general functions */
  scm_c_define_gsubr ("quit", 0, 0, 0, g_quit);
  scm_c_define_gsubr ("exit", 0, 0, 0, g_quit);

  /* gattrib functions */
  scm_c_define_gsubr ("gattrib-version", 1, 0, 0, g_rc_gattrib_version);

}

/*! \brief Scheme function to quit the application
 *
 * Quit the application from within Scheme.
 */
SCM g_quit(void)
{
#ifdef DEBUG
  printf("In g_quit, calling exit(0)\n");
#endif

  gattrib_quit(0);
  /*  exit(0);  */  /* Necessary? */

  /* we don't really get here, but otherwise gcc complains */
  return SCM_BOOL_F;
}

